<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/19
 * Time: 16:25
 */
class 文件读写
{

}

$handle  = @ fopen ( "demo.txt" ,  "r" );
if ( $handle ) {
    while (( $buffer  =  fgets ( $handle ,  4096 )) !==  false ) {
        echo  $buffer ;
    }
    if (! feof ( $handle )) {
        echo  "Error: unexpected fgets() fail\n" ;
    }
    fclose ( $handle );
}

echo '<hr/>';

$length= readfile("demo.txt");

echo '<hr/>';

$file_str = 'demo.txt';

if(file_exists($file_str))
{
    echo file_get_contents($file_str);

}